<template>
	<view class="container fz12">
		<view class="menu-list disb aic">
			<text class="fz12">姓名</text>
			<u-input v-model="user.name" type="text" placeholder="请输入姓名" fontSize='12' :border="false" input-align="right" />
		</view>
		<view class="menu-list disb aic" @click="click(3)">
			<text class="fz12">性别</text>
			<view class="disp aic">
				<text class="fz12">{{sex}}</text>
				<image class="right" src="../../static/images/preat/right.png" mode=""></image>
			</view>
		</view>
		<view class="menu-list disb aic">
			<text class="fz12">年龄</text>
			<u-input v-model="user.age" type="text" placeholder="请输入" fontSize='12' :border="false" input-align="right" />
		</view>
		<view class="menu-list disb aic">
			<text class="fz12">手机号</text>
			<u-input v-model="user.mobile" type="text" placeholder="请输入" :border="false" fontSize='12' input-align="right" />
		</view>
		<view class="menu-list disb aic" @click="click(1)">
			<text class="fz12">户籍</text>
			<view class="disp aic">
				<text :class="user.censusRegister?'':'colorc'">{{user.censusRegister?user.censusRegister:'请选择'}}</text>
				<image class="right" src="../../static/images/preat/right.png" mode=""></image>
			</view>
		</view>
		<view class="menu-list disb aic" @click="click(2)">
			<text class="fz12">户口</text>
			<view class="disp aic">
				<text :class="user.registeredHk?'':'colorc'">{{user.registeredHk?user.registeredHk:'请选择'}}</text>
				<image class="right" src="../../static/images/preat/right.png" mode=""></image>
			</view>
		</view>
		<view class="menu-list disb aic">
			<text class="fz12">房产信息</text>
			<image class="right" src="../../static/images/preat/right.png" mode=""></image>
		</view>
		<view class="menu-list disb aic">
			<text class="fz12">车辆信息</text>
			<image class="right" src="../../static/images/preat/right.png" mode=""></image>
		</view>
		<u-action-sheet :actions="list" :title="title" :show="show" @select='select' @close='show=false'></u-action-sheet>
		<view class="upBtn tac colorf" @click="upLoad">提交</view>
	</view>
</template>

<script>
	import {salesmanAddUser} from "../../api/cart.js"
export default {
	data() {
		return {
			user:{},
			sex:'',
			show:false,
			title:'',
			list:[],
			selectId:null,
		}
	},
	methods: {
		click(i){
			this.show = true
			this.selectId = i
			if(i==1){
				this.title = '选择户籍'
				this.list = [
					{name: '重庆本地'},
					{name: '重庆外省'},
				]
			}
			if(i==2){
				this.title = '选择户口'
				this.list = [
					{name: '城市户口'},
					{name: '农村户口'},
				]
			}
			if(i==3){
				this.title = '选择性别'
				this.list = [
					{name: '男',num:1},
					{name: '女',num:2},
					{name: '未知',num:3},
				]
			}
		},
		//选择
		select(e){
			this.show = false
			if(this.selectId==1){
				this.user.censusRegister = e.name
			}
			if(this.selectId==2){
				this.user.registeredHk = e.name
			}
			if(this.selectId==3){
				this.sex = e.name
				this.user.sex = e.num
			}
		},
		//提交
		upLoad(){
			salesmanAddUser(this.user).then(res => {
				if(res.code==0){
					this.$u.toast('添加成功')
					setTimeout(()=>{
						uni.navigateBack()
					},1000)
				}else{
					this.$u.toast(res.msg)
				}
			})
		}
	}
}
</script>

<style lang="scss" scoped>
.container{
	min-height: 100vh;
	background-color: #f7f7f7;
	.menu-list{
		padding: 20rpx 30rpx;
		margin: 5rpx 0;
		background-color: #fff;
		.changeUserImage{
			width: 50rpx;
			height: 50rpx;
			border-radius: 50%;
			.userPic{
				width: 50rpx;
				height: 50rpx;
				border-radius: 50%;
			}
		}
		.right{
			width: 20rpx;
			height: 30rpx;
			margin-left: 20rpx;
		}
		.colorc{
			color: #d6d6d6;
		}
		.nickname{
			text-align: right;
		}
	}
}
.modify{
	width: 80%;
	line-height: 80rpx;
	margin: 40rpx auto 0;
	border-radius: 40rpx;
	background-color: #0055ff;
}
.upBtn{
	width: 80%;
	line-height: 80rpx;
	border-radius: 40rpx;
	background-color: rgb(61, 106, 246);
	margin: 40rpx auto 0;
}
</style>
